package com.chiyou.common.utils;

import java.util.Map;

import net.sf.json.JSONObject;

public class JSONUtil {
	/**
	 * json转化成java对象。类似： {"id" : idValue, "name" : nameValue,"aBean":{"aBeanId"
	 * : aBeanIdValue, ...}}
	 * 
	 * @param jsonString
	 * @param clazz
	 * @param map
	 *            集合属性的类型 (key : 集合属性名, value : 集合属性类型class) example:
	 *            ("paramsObj" : Bean.class)
	 * @return
	 */
	public static Object getJTO(String jsonString, Class clazz, Map map) {
		JSONObject jsonObject = null;
		try {
			jsonObject = JSONObject.fromObject(jsonString.trim());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return JSONObject.toBean(jsonObject, clazz, map);
	}
}
